<?php $this->load->view('header'); ?>
<div id="title_background">
	<div class="wrapper">
		<h1>Artikel</h1>
	</div> 
</div>
</div>
<div class="cleaner"></div>
<div id="position_navi"><a href="<?php echo base_url();?>">Beranda</a> / Artikel</div>
    <div id="content">
    
    <div id="sidebar_right">
    	<?php $this->load->view('right_sidebar', $right_sidebar); ?>
    </div>
	
	<div id="data-artikel">
    <?php 
	if(count($articles)>0){
		foreach($articles as $article){ ?>
			<article class="sidebar_right">
				<h2 class="blog_post_title"><a href="<?php echo base_url();?>articles/detail/<?php echo $article['id_artikel'];?>"><?php echo $article['judul'];?></a></h2>
				<div class="blog_post_info_div">
					<span class="blog_post_info">Diposting oleh <?php echo $article['writer'];?>, Pada <?php echo timestamp_to_date_time($article['waktu_posting']); ?></span>
					<span class="blog_post_info_right">
						<?php foreach($total_comments as $a){
								foreach($a as $total_comment){
									if($total_comment['id_artikel'] == $article['id_artikel']){
										echo $total_comment['total_komentar'] ." komentar";
									}
								}
						}?>
					</span>
				</div>
				<img class="blog_post_picture float" style="width:auto !important; height:auto !important" src="<?php echo base_url()."images/article_images/" . $article['foto'];?>" />            
				<?php echo substr($article['isi'], 0, 500); ?> ....</p>
				<a class="learn_more" href="<?php echo base_url()."articles/detail/".$article['id_artikel'];?>">Selengkapnya</a>
				<hr />
			</article>
		<?php }  
	}else{
		echo '<article class="sidebar_right"><span>Tidak ada artikel</span></article>';
	}?>
	</div>  
	<div class="cleaner"></div>
	<?php if(count($articles) > 0){ ?>
		<article class="sidebar_right" id="pagination"> </article>
	<?php } ?>
	<div class="cleaner"></div>
    </div>
    <div class="cleaner"></div>
<?php $this->load->view('footer', $right_sidebar);?>

<script type="text/javascript">
    $(document).ready(function () {
        $('#pagination').smartpaginator({ totalrecords: <?php echo count($articles); ?>, recordsperpage: 5, length: 5, datacontainer: 'data-artikel', dataelement: 'article', initval: 0, next: 'Next', prev: 'Prev', first: 'First', last: 'Last'});
    });
</script>